<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>应用管理</title> {{>/WEB-INF/pages/common/meta_base.part.html}}
{{>/WEB-INF/pages/common/refs_base.part.html}}
{{>/WEB-INF/pages/common/refs_modal.part.html}}
{{>/WEB-INF/pages/common/refs_plupload.part.html}}
<style type="">
.ui-selected {
	background: none repeat scroll 0 0 #E5F1FD;
	border: 1px solid #8EC7FF;
	border-radius: 8px 8px 8px 8px;
	/*margin: 0 20px 0 20px;*/
}
</style>
</head>
<body>
	<!-- <div class="container"> -->
	{{>/WEB-INF/pages/common/layout_header.part.html}}

	<!--Con//Start-->
	<div class="container">
		<ul class="breadcrumb">
			<li><a href="{{ctx}}">首页</a></li>
			<li><a href="{{ctx}}/mam/appMain/list-view">应用管理</a></li>
			<li class="active">{{appMainVo.app_name}}</li>
		</ul>

		<hr class="hr1" />
		<div class="hr-10"></div>
		<div class="bor-tab bg-st-white text-center">
			<div class="tit3-st">{{appMainVo.app_name}}</div>
			<div class="mar-st-a30">
				<div class="bor-bot pad-st-b2">
					<div class="text-left tit4-st col-6">应用基本信息</div>
					<p class="btn-w text-right">
						<button class="btn btn-sm btn-primary tls" type="button"
							data-toggle="modal" onclick="appEdit('{{appMainVo.id}}')">编辑</button>
						<button type="button" class="btn tls btn-common btn-sm" value="删除"
							onclick="deleteApp('{{appMainVo.id}}')">删除</button>
					</p>
				</div>
				<div class="pad-st-b10 row">
					<div class="col-sm-9">
						<div class="col-sm-3">
							<img class="img-rounded info-icon"
								style="width: 106px; height: 106px; cursor: pointer"
								id="appIcon" />
						</div>
						<div class="col-sm-9 text-left">
							<ul class="list-li">
								<li>应用名称：{{appMainVo.app_name}}</li>
								<li>应用标识：{{appMainVo.identifier}}</li>
								<li>应用类别：{{appMainVo.appCategoryVo.name}}</li>
								<li>appKey：{{appKey}}</li>
								<li>应用密钥：{{appMainVo.secret}}</li>
								<li>下载量：{{appMainVo.download_counter}}次</li>
								<li>创建时间： <script type="text/javascript">
									document.write($.format.date(
											"{{appMainVo.create_time}}",
											"yyyy-MM-dd HH:mm"))
								</script></li>
								<li>修改时间： <script type="text/javascript">
									document.write($.format.date(
											"{{appMainVo.modified_time}}",
											"yyyy-MM-dd HH:mm"))
								</script></li>
								<li>应用简介：<span class="">{{appMainVo.discription}}</span></li>
							</ul>
						</div>
					</div>
					<div class="col-sm-3 bor-le">
						<div class="row jbxx-img">
							<p>云服务</p>
							<ul>
								{{#cloudList}}
								<li><a href="{{ctx}}{{pageUrl}}?appId={{appMainVo.id}}"><img
										style="width: 53px; height: 45px; cursor: pointer"
										src="{{ctx}}/{{icon}}" />
										<p>{{name}}</p></a></li> {{/cloudList}}
								<li><img src="{{ctx}}/static/bsl/images/icon_07.png"
									data-toggle="tooltip" title="添加云服务"
									style="width: 75px; height: 75px; cursor: pointer"
									onclick="appCloud('{{appMainVo.id}}')" data-toggle="modal" /></li>
							</ul>
						</div>
					</div>
				</div>
				<div class="bg-st-gary pad-st-a10 container">
					<div class="col-lg-4 row" id="colsm_android" style="margin: 0;">
						<div class="col-sm-4" style="margin-top: 30px"
							onclick="platformVersion('android','{{appMainVo.id}}')">
							<ul class="list-li">
								<li><img
									style="width: 106px; height: 106px; cursor: pointer"
									class="img-rounded info-icon"
									src="{{ctx}}/static/bsl/images/android002.gif" /></li>
								<li style="white-space: nowrap;">下载量：{{androidPub.plat_counter}}次</li>
							</ul>
						</div>
						<div class="col-sm-8 text-left line-26"
							style="padding-right: 1px;">
							<dl>
								<dd>
									<a class="btn-sm btn-primary" style="padding: 0.25em 0.6em"
										href="####"
										onclick="appVersionAdd('android','{{appMainVo.id}}')">添加版本</a>
									<a class="btn-info btn-sm" style="padding: 0.25em 0.6em"
										href="####" id="androidPubDD"
										onclick="openCloneView('{{androidPub.id}}')">克隆</a>
								</dd>

								<dd>
									<span class="label btn-info"
										style="line-height: 30px; padding: 0.25em 0.6em">上架版本：{{androidPub.version}}</span>
								</dd>
								<script>
									var pubAndroidVersion = "{{androidPub.version}}";
									if (!pubAndroidVersion
											|| pubAndroidVersion == "") {
										$("#androidPubDD").hide();
									}
								</script>

								<dd>构建号：{{androidPub.build}}</dd>
								<dd>
									完成时间：
									<script type="text/javascript">
										document.write($.format.date(
												"{{androidPub.create_time}}",
												"yyyy-MM-dd HH:mm"))
									</script>
								</dd>
								<dd>
									上架时间：
									<script type="text/javascript">
										document.write($.format.date(
												"{{androidPub.modified_time}}",
												"yyyy-MM-dd HH:mm"))
									</script>
								</dd>
								<dd>
									下载： <a class="btn-info btn-sm" id="android"
										href="{{ctx}}/mam/apps/download/{{appMainVo.identifier}}/{{androidPub.version}}/{{androidPub.platformid}}?appKey={{appKey}}">android安装包</a>
									<script>
										var androidBundle = "{{androidPub.bundle}}";
										if (!androidBundle
												|| androidBundle == ""
												|| androidBundle == null) {
											$("#android").hide();
										} else {
											$("#android").show();
										}
									</script>
								</dd>
								<br />
							</dl>
						</div>
					</div>

					<div class="col-lg-4 row " id="colsm_ios" style="margin: 0;">
						<div class="col-sm-4" style="margin-top: 30px">
							<ul class="list-li">
								<li><img
									style="width: 106px; height: 106px; cursor: pointer"
									onclick="platformVersion('ios','{{appMainVo.id}}')"
									class="img-rounded info-icon"
									src="{{ctx}}/static/bsl/images/ios002.gif" /></li>
								<li style="white-space: nowrap;">下载量：{{iosPub.plat_counter}}次</li>
							</ul>
						</div>
						<div class="col-sm-8 text-left line-26"
							style="padding-right: 1px;">
							<dl>
								<dd>
									<a class="btn-sm btn-primary" style="padding: 0.25em 0.6em"
										href="####" onclick="appVersionAdd('ios','{{appMainVo.id}}')">添加版本</a>
									<a class="btn-info btn-sm" style="padding: 0.25em 0.6em;"
										href="####" id="iosPubDD"
										onclick="openCloneView('{{iosPub.id}}')">克隆</a>
								</dd>

								<dd>
									<span class="label btn-info"
										style="line-height: 30px; padding: 0.25em 0.6em;">上架版本：{{iosPub.version}}</span>
								</dd>
								<script>
									var pubAndroidVersion = "{{iosPub.version}}";
									if (!pubAndroidVersion
											|| pubAndroidVersion == "") {
										$("#iosPubDD").hide();
									}
								</script>

								<dd>构建号：{{iosPub.build}}</dd>
								<dd>
									完成时间：
									<script type="text/javascript">
										document.write($.format.date(
												"{{iosPub.create_time}}",
												"yyyy-MM-dd HH:mm"))
									</script>
								</dd>
								<dd>
									上架时间：
									<script type="text/javascript">
										document.write($.format.date(
												"{{iosPub.modified_time}}",
												"yyyy-MM-dd HH:mm"))
									</script>
								</dd>
								<dd>
									下载： <a class="btn-info btn-sm" id="ios"
										style="line-height: 30px;"
										href="{{ctx}}/mam/apps/download/{{appMainVo.identifier}}/{{iosPub.version}}/{{iosPub.platformid}}?appKey={{appKey}}">ios安装包</a>
									<script>
										var iosBundle = "{{iosPub.bundle}}";
										if (!iosBundle || iosBundle == ""
												|| iosBundle == null) {
											$("#ios").hide();
										} else {
											$("#ios").show();
										}
									</script>
								</dd>
							</dl>
						</div>
					</div>
					<!-- 
					<div class="col-lg-4 row" id="colsm_winphone">
						<div class="col-sm-4" style="margin-top: 14px">
							<img style="width: 106px; height: 106px; cursor: pointer"
								class="img-rounded info-icon"
								src="{{ctx}}/static/bsl/images/winphone002.gif" />
						</div>
						<div class="col-sm-8 text-left line-26">
							<dl>
								<dd>
									<a class="btn btn-sm btn-primary tls"
										onclick="appVersionAdd('winphone','{{appMainVo.id}}')">添加版本</a>
								</dd>
								<dd>
									<span class="label btn-info">已上架版本</span>
								</dd>
								<dd>下载量：次</dd>
								<dd>构建号：</dd>
							</dl>
						</div>
					</div>
					 -->
				</div>
				<div class="hr-10"></div>
				<div class="hr"></div>
			</div>
		</div>
		<div class="container bg-st-white" id="versionListpanel"
			style="display: none"></div>
	</div>
	<!--Con//End-->
	<!--Foot//Start-->
	<!--boostrap 弹框 -->
	{{>/WEB-INF/pages/app/widget-modal.html}}
	<!-- footer 脚本 -->
	{{>/WEB-INF/pages/common/layout_footer.part.html}}
</body>
</html>
<script type="text/javascript">
	//判断图标是否存在，如果存在就显示，不存在就显示默认图标
	var icon_id = "{{appMainVo.icon}}";
	if (icon_id != "") {
		jQuery("#appIcon").attr("src",
				"{{ctx}}/mam/attachment/download/{{appMainVo.icon}}");
	} else {
		jQuery("#appIcon").attr("src", "{{ctx}}/static/bsl/images/defind.png");
	}

	//进入添加版本页面
	function appVersionAdd(platform, appid) {
		window.location.href = "{{ctx}}/mam/appversions/" + platform
				+ "?appId=" + appid;
	}
	//显示版本列表
	function platformVersion(platform, appid) {
		var loadurl = "{{ctx}}/mam/appversions/" + platform + "/list?appId="
				+ appid;
		$('div').find(".col-lg-4").each(function(index) {
			$(this).removeClass('ui-selected');
		});
		$('#colsm_' + platform).toggleClass("ui-selected")
		$.get(loadurl, function(data) {
			$('#versionListpanel').html(data)
		});
		$('#versionListpanel').show();
	}

	//进入编辑页面
	function appEdit(appId) {
		var loadurl = '{{ctx}}/mam/appMain/update-view?appId=' + appId;
		$.get(loadurl, function(data) {
			bootbox.dialog({
				message : data,
				title : "编辑应用",
				buttons : {
					canel : {
						label : "关闭",
						className : "btn btn-common btn-sm tls"
					},
					success : {
						label : "保存",
						className : "btn btn-primary btn-sm tls",
						callback : function() {
							formSubmit();
							return false;
						}
					}
				}
			});
		});
	}

	//关联云服务
	function appCloud(appId) {
		var op = {
			remote : '{{ctx}}/mam/appMain/cloud/view?appId=' + appId,
			show : true
		};
		$('#btn_modal').unbind();
		$('#btn_modal').bind("click", function() {
			saveCloud(appId);
		});
		$('#myModal').modal(op);
	}

	//删除应用
	function deleteApp(appId) {
		bootbox.confirm("该操作将会删除应用及其所有版本,是否确认删除?", function(result) {
			if (result) {
				$.ajax({
					type : "GET",
					dataType : "json",
					url : '{{ctx}}/mam/appMain/' + appId + "/delete",
					success : function(data, textStatus) {
						if (data.result == "success") {
							var url = "{{ctx}}/mam/appMain/list-view";
							bootbox.alert("删除成功", function() {
								window.location.href = url;
							});
						} else if (data.result == "false") {
							bootbox.alert(data.msg);
						} else {
							bootbox.alert("删除失败，请稍后再试！");
						}
					},
					error : function(data, status, e) {
						bootbox.alert("系统繁忙，请稍后再试！");
					}
				});
			}
		});
	}

	//克隆版本
	function openCloneView(cloneId) {
		var op = {
			remote : '{{ctx}}/mam/appversions/{platform}/clone/' + cloneId
					+ '?appId={{appMainVo.id}}',
			show : true
		};
		$('#btn_modal').unbind();
		$('#btn_modal').bind("click", function() {
			dataCloneForm();
		});
		$('#myModal').modal(op);
	}
</script>

